package com.nbsaas.boot.order.rest.convert;

import com.nbsaas.boot.order.data.entity.OrderItem;
import com.nbsaas.boot.order.api.domain.simple.OrderItemSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* -列表对象转换器
*/

public class OrderItemSimpleConvert implements Converter<OrderItemSimple, OrderItem> {




@Override
public OrderItemSimple convert(OrderItem source) {
    OrderItemSimple result = new OrderItemSimple();

                result.setProductId(source.getProductId());
                result.setNum(source.getNum());
                result.setActualAmount(source.getActualAmount());
                if(source.getSkuType()!=null){
                   Map<Integer,String> SkuTypeMap=new HashMap<>();
                       SkuTypeMap.put(1,"商品");
                       SkuTypeMap.put(2,"sku");
                   String label=  SkuTypeMap.get(source.getSkuType());
                   result.setSkuTypeName(label);
                }
                result.setSkuType(source.getSkuType());
                result.setAddDate(source.getAddDate());
                result.setProductName(source.getProductName());
                result.setParentId(source.getParentId());
                result.setSkuName(source.getSkuName());
                result.setTotal(source.getTotal());
                result.setPrice(source.getPrice());
                result.setTotalDiscount(source.getTotalDiscount());
                result.setId(source.getId());
                result.setSkuId(source.getSkuId());

               try {
                   if(source.getOrder()!=null){
                       result.setOrder(source.getOrder().getId());
                   }
                } catch (Exception ignored) { }

                result.setLastDate(source.getLastDate());


    return result;
}

}